package com.example.shoppingmallspringboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shoppingmallspringboot.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface CommentMapper extends BaseMapper<Comment>{
    @Select("SELECT comment.goods_id,comment.user_id,comment.content,comment.score,comment.create_time,user.username,user.profile,uniappuser.nick_name,uniappuser.avatar_url " +
            "FROM comment LEFT JOIN uniappuser ON comment.user_id = uniappuser.id LEFT JOIN user ON comment.user_id = user.id  WHERE comment.goods_id=#{id}")
    List<Map<String,Object>> getComment(int id);
}
